﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Content/Master.Master" ValidateRequest="false" Inherits="System.Web.Mvc.ViewPage<SCS.Core.Models.Collection.ArticleCollection>" %>
<%@ Import Namespace="SCS.Core" %>
<%@ Import Namespace="SCS.Core.Models" %>
<%@ Import Namespace="SCS.Core.ViewModels" %>
<%@ Import Namespace="SCS.Core.Controllers" %>
<%@ Import Namespace="SCSService" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Chi tiết bài viết
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
      <script type="text/javascript" src="/ThemeExtends/AdminSkin/js/jquery.flot.js"></script>
    <script type="text/javascript" src="/ThemeExtends/AdminSkin/js/jquery.flot.stack.js"></script>	
    <link rel="stylesheet" type="text/css" href="/Content/smoothness-1.8.13/jquery-ui-1.8.13.custom.css"/>
    <link rel="stylesheet" type="text/css" href="/Content/smoothness-1.8.13/ui.dropdownchecklist.themeroller.css"/>
    <script type="text/javascript" src="/Scripts/jquery-1.6.1.min.js"></script>
    <script type="text/javascript" src="/Scripts/jquery-ui-1.8.13.custom.min.js"></script>
    <script type="text/javascript" src="/Scripts/ui.dropdownchecklist-1.4-min.js"></script>
    <script type="text/javascript" src="/Scripts/ui.dropdownchecklist.js"></script>
    <%--Validator--%>
    <script src="/Scripts/jquery.validate.min.js" type="text/javascript"></script>
    <script src="/Scripts/MicrosoftMvcJQueryValidation.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(function () {

            $("#CategoriesID").dropdownchecklist({ icon: {}, width: 350, firstItemChecksAll: false, explicitClose: '...X', forceMultiple: true
            , onComplete: function (selector) {
                var values = "";
                for (i = 0; i < selector.options.length; i++) {
                    if (selector.options[i].selected && (selector.options[i].value != "")) {
                        if (values != "") values += ",";
                        values += selector.options[i].value;
                    }
                }
                
                if (document.all || document.getElementById)
                    document.getElementById('ArrayArticleCategoryID').value = values;
                else
                    document.getElementById('ArrayArticleCategoryID').setAttribute("value", values);

            }
            , onItemClick: function (checkbox, selector) {
                var justChecked = checkbox.prop("checked");
                var checkCount = (justChecked) ? 1 : -1;
                for (i = 0; i < selector.options.length; i++) {
                    if (selector.options[i].selected) checkCount += 1;
                }
            }
         });



        });
    </script>

    <!--Editor-->
    <link rel="stylesheet" href="/Editor/themes/default/default.css" />
	<link rel="stylesheet" href="/Editor/plugins/code/prettify.css" />
	<script type="text/javascript" charset="utf-8" src="/Editor/kindeditor.js"></script>
	<script type="text/javascript" charset="utf-8" src="/Editor/lang/en_US.js"></script>
	<script type="text/javascript" charset="utf-8" src="/Editor/plugins/code/prettify.js"></script>
	<script type="text/javascript">
	    KindEditor.ready(function (K) {
	        var editor1 = K.create('#FullText', {
	            cssPath: '/Editor/plugins/code/prettify.css',
	            uploadJson: '/Editor/aspnet/upload_json.ashx',
	            fileManagerJson: '/Editor/aspnet/file_manager_json.ashx',
	            allowFileManager: true,
	            afterCreate: function () {
	                var self = this;
	                K.ctrl(document, 13, function () {
	                    self.sync();
	                    K('form[name=example]')[0].submit();
	                });
	                K.ctrl(self.edit.doc, 13, function () {
	                    self.sync();
	                    K('form[name=example]')[0].submit();
	                });
	            }
              
	        });
	        prettyPrint();
	    });
	</script>
    <%--<script type="text/javascript">
        KindEditor.ready(function (K) {
            var editor2 = K.create('#IntroText', {
                cssPath: '/Editor/plugins/code/prettify.css',
                uploadJson: '/Editor/aspnet/upload_json.ashx',
                fileManagerJson: '/Editor/aspnet/file_manager_json.ashx',
                allowFileManager: true,
                afterCreate: function () {
                    var self = this;
                    K.ctrl(document, 13, function () {
                        self.sync();
                        K('form[name=example]')[0].submit();
                    });
                    K.ctrl(self.edit.doc, 13, function () {
                        self.sync();
                        K('form[name=example]')[0].submit();
                    });
                }

            });
            prettyPrint();
        });
	</script>--%>
    <!--End Editor-->
    
   <% Html.EnableClientValidation(); %>
   <% using (Html.BeginForm((bool)ViewData["IsAdd"] ? "SaveAddArticle" : "SaveEditArticle", "ArticaleMaster", FormMethod.Post, new { siteGuid = "sendFileForm", language = "sendFileForm", id = "sendFileForm", enctype = "multipart/form-data" }))
            {%>
    <div class="column half fl">
        <div class="box ">
		    <h2 class="box-header"><%=(bool)ViewData["IsAdd"] ? "New Article" : "Edit Article"%>
                Bài viết</h2>
           
		    <div class="box-content">
                
                <label class="form-label"> Tiêu đề </label>
                <%= Html.TextBoxFor(m => m.Title, new { @class = "form-field full" })%> <span style="color:Red;font-weight:bold"><%= Html.ValidationMessageFor(m => m.Title) %></span>

<%--                <label class="form-label"> Alias </label>
                <%= Html.TextBoxFor(m => m.Alias, new { @class = "form-field full" })%> <span style="color:Red;font-weight:bold"><%= Html.ValidationMessageFor(m => m.Alias) %></span>--%>
                
                <%=Html.HiddenFor(m=>m.Alias) %>

                <label class="form-label"> Trích dẫn </label>
                <%= Html.TextAreaFor(m => m.IntroText, new { @class = "form-field width60" })%>
                                   
                <label class="form-label"> Chuyên mục </label>
                <%= Html.DropDownList("CategoriesID", (MultiSelectList)ViewData["ListArticleCategoryDrop"], "Select all", new { @multiple = "multiple" })%> <span style="color:Red;font-weight:bold"><%= Html.ValidationMessageFor(m => m.ArrayArticleCategoryID) %></span>
                 
                 <label class="form-label"> Kích hoạt </label>
                 <%if (Model.Active == true)
                   {
                   %>
                       
                        <%=Html.CheckBoxFor(m=>m.Active,true) %>
                   <%
                     }
                   else
                   {
                       if ((bool)ViewData["IsAdd"])
                       {
                       %>
                        <%=Html.CheckBoxFor(m=>m.Active,true) %>
                       <%
                       }
                       else
                       { 
                       %>
                        <%=Html.CheckBoxFor(m=>m.Active) %>
                       <%
                       }
                    
                   } 
                    %>
                 <label class="form-label"> Nội dung </label>
                 <%= Html.TextAreaFor(m => m.FullText, new { @class = "form-field full" })%>
                 
                 <%=Html.TextBoxFor(m => m.CategoriesID, new { @Style = "display:none" })%>

                 <%=Html.TextBoxFor(m => m.ArrayArticleCategoryID, new { @Style = "display:none" })%>
                 
                 <%=Html.HiddenFor(m=>m.ArticleID) %>
                 <%=Html.HiddenFor(m=>m.Created) %>
                 <%=Html.HiddenFor(m=>m.Modified) %>
                 <%=Html.HiddenFor(m=>m.Url) %>
                 <%=Html.HiddenFor(m=>m.CreatedBy) %>
                 <%=Html.HiddenFor(m=>m.Version) %>
                 <%=Html.HiddenFor(m=>m.Hits) %>
                 <%=Html.HiddenFor(m=>m.Ordering) %>
                 <%=Html.HiddenFor(m=>m.Attribs) %>
                 <%=Html.HiddenFor(m=>m.Access) %>
                 <%=Html.HiddenFor(m=>m.CheckedOut) %>
                 <%=Html.HiddenFor(m=>m.CheckedOutTime) %>
                 <%=Html.HiddenFor(m=>m.PublicUp) %>
                 <%=Html.HiddenFor(m=>m.PublicDown) %>
                 <%=Html.HiddenFor(m=>m.Tags) %>
                 <%=Html.HiddenFor(m=>m.Related) %>
                 <p>
                <%=ViewData["Result"]%> 
                </p>
                                   
                  <input type="submit" value="" class="button white_input save_input " style="width: 74px;height: 28px; float:left; margin-right:10px;"/> <!--Button Save-->
                  <a class="button white" href="javascript:history.back();"><span class="icon_text cancel"></span>Đóng</a> <!--Button Close-->
               
	        </div>
	    </div>
	     <div class="clear"></div>    
    </div>
    <div class="column half fr">
        <div class="box ">
		<h2 class="box-header">Metadata</h2>
		    <div class="box-content">
                
                <label class="form-label"> Images </label>
                <%if (Model.Images != null)
                  {
                      string src = Model.Images;
                       
                           %>
                            
                               <img src="http://image.atf.com.vn/<%=Model.Images %>" id="imgname" width="150px" alt="" onclick="window.open('/Editor/aspnet/Images.aspx','images',' width=750,height=450,left=150,top=200,toolbar=no,status=0,scrollbars=1,location=0,');" />  
                           <%
                  }
                  else
                  { 
                     %>
                               <img src="/Content/images/noimage.gif" width="130px" id="imgname" alt="" onclick="window.open('/Editor/aspnet/Images.aspx','images',' width=750,height=450,left=150,top=200,toolbar=no,status=0,scrollbars=1,location=0,');" />
                     <%
                  }
                  %>
                  <%=Html.HiddenFor(m=>m.Images) %>
                <label class="form-label"> Url </label>
                <%= Html.TextBoxFor(m => m.Url, new { @class = "form-field full" })%>

                <label class="form-label"> Tags </label>
                <%= Html.TextBoxFor(m => m.Tags, new { @class = "form-field full" })%>

                <label class="form-label"> MetaKey </label>
                <%= Html.TextAreaFor(m => m.MetaKey, new { @class = "form-field half" })%>

                <label class="form-label"> MetaDesc </label>
                <%= Html.TextAreaFor(m => m.MetaDesc, new { @class = "form-field width60" })%>

                <label class="form-label"> MetaData </label>
                <%= Html.TextAreaFor(m => m.MetaData, new { @class = "form-field width60" })%>

            </div>
        </div>
        
	</div>     
     <div class="clear"></div>
       
 
    <% } %>
    <script type="text/javascript">
        var selecteds = document.getElementById("ArrayArticleCategoryID").value;
        var combox = document.getElementById("CategoriesID");
        var arrSeleteds = selecteds.split(",");
        for (i = 0; i < combox.options.length; i++) {
            for (j = 0; j < arrSeleteds.length; j++) {
                if (combox.options[i].value == arrSeleteds[j]) {
                    combox.options[i].selected=true;
                }
            }

        }

    </script>
    
</asp:Content>
